import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  // {
  //   path: '/',
  //   redirect: '/layout'
  // },
  // 配置登录页面路由
  {
    path: '/login',
    // 设置路由的名称，命名路由。
    name: 'login',
    component: () => import('@/views/login/index.vue')
  },
  // 配置页面组件布局路由
  {
    path: '/',
    name: 'layout',
    // 如果父路由有默认子路由, 那它的name没有意义
    // 防止后续页面模块跳转问题
    // redirect: '/layout/',
    component: () => import('@/views/layout'),
    children: [
      {
        path: '/',
        redirect: '/home'
      },
      {
        path: 'home', // 默认子路由
        name: 'home',
        component: () => import('@/views/home')
      },
      {
        path: 'qa',
        name: 'qa',
        component: () => import('@/views/qa')
      },
      {
        path: 'video',
        name: 'video',
        component: () => import('@/views/video')
      },
      {
        path: 'my',
        name: 'my',
        component: () => import('@/views/my')
      }
    ]
  }
]

const router = new VueRouter({
  routes
})

export default router
